class MinStack {
public:
    list<int> s1,s2; //s1为源栈 s2为辅助栈为当前的最小值
    const int INF=INT_MAX; 
    MinStack() {
        s2.push_front(INF);
    }
    
    void push(int val) {
        s1.push_front(val); 
        if(val<s2.front()){ //若压入栈的值比s2的上一个值小 那当前的最小值为val 反之还是s2的上一个值
            s2.push_front(val);
        }else{
            s2.push_front(s2.front());
        }
    }
    
    void pop() {
        s1.pop_front();
        s2.pop_front();
    }
    
    int top() {
        return s1.front();
    }
    
    int getMin() {
        return s2.front();
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(val);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->getMin();
 */ //栈的特点 先进后出 只要value还在 那后续改动都不会影响value